package my.interview;

import java.util.Scanner;
import java.util.TreeSet;

public class Main3 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String key = scanner.nextLine();
        String box = scanner.nextLine();
        int result = getResult(key, box);
        System.out.println(result);
    }

    private static int getResult(String key, String box) {
        String[] split = box.substring(2).split(" ");
        for (int i = 0; i < split.length; i++) {
            String lowerCase = split[i].toLowerCase();
            TreeSet<Character> treeSet = new TreeSet<>();
            for (char c : lowerCase.toCharArray()) {
                if (c >= 'a' && c <= 'z') {
                    treeSet.add(c);
                }
            }
            if (treeSet.size() == key.length()) {
                StringBuilder stringBuilder = new StringBuilder();
                for (Character c : treeSet) {
                    stringBuilder.append(c);
                }
                if (stringBuilder.toString().equals(key)) {
                    return i + 1;
                }
            }
        }
        return -1;
    }
}
